﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GN.Pay.TradeChannel
{
    /// <summary>
    /// 交易通道信息
    /// </summary>
    [Serializable]
    public class TradeChannelInfo: IChannel
    {
        /// <summary>
        /// 实例化 TradeChannelType 类新实例
        /// </summary>
        /// <param name="channelId">通道Id</param>
        /// <param name="channelName">通道名称</param>
        private TradeChannelInfo(string channelId, string channelName)
        {
            this.ChannelId = channelId;
            this.ChannelName = channelName;
        }

        /// <summary>
        /// 创建
        /// </summary>
        /// <param name="channelId">通道Id</param>
        /// <param name="channelName">通道名称</param>
        /// <returns></returns>
        public static TradeChannelInfo Create(string channelId, string channelName)
        {
            if (string.IsNullOrWhiteSpace(channelId))
            {
                throw new ArgumentNullException(nameof(channelId));
            }
            if (string.IsNullOrWhiteSpace(channelName))
            {
                throw new ArgumentNullException(nameof(channelName));
            }
            if (channelId.Length > 32)
            {
                throw new ArgumentOutOfRangeException(nameof(channelId),
                    nameof(channelId) + " Length 超过 32");
            }
            if (channelName.Length > 50)
            {
                throw new ArgumentOutOfRangeException(nameof(channelName),
                    nameof(channelName) + " Length 超过 50");
            }
            return new TradeChannelInfo(channelId, channelName);
        }

        /// <summary>
        /// 获取通道Id
        /// </summary>
        public string ChannelId { get; private set; }

        /// <summary>
        /// 获取通道名称
        /// </summary>
        public string ChannelName { get; private set; }
    }
}
